package com.quanquan.utils;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;

public class TencentCaptcha {
    private int aid ;
    private String AppSecretKey ;

    public int getAid() {
        return aid;
    }

    public void setAid(int aid) {
        this.aid = aid;
    }

    public String getAppSecretKey() {
        return AppSecretKey;
    }

    public void setAppSecretKey(String appSecretKey) {
        AppSecretKey = appSecretKey;
    }

    public TencentCaptcha(){}

    String url = "https://ssl.captcha.qq.com/ticket/verify";


    public TencentCaptcha(int aid, String AppSecretKey) throws Exception {
        this.aid = aid;
        this.AppSecretKey = AppSecretKey;
    }

    public JSONObject verify (String ticket, String randstr , String ip) {
        String wholeUrl = String.format("%s?aid=%s&AppSecretKey=%s&Ticket=%s&Randstr=%s&UserIP=%s", url, aid , AppSecretKey, ticket, randstr, ip);
        String content = HttpUtils.getHttpResponse(wholeUrl);
        JSONObject json =  JSON.parseObject(content);
        return json;
    }
}
